﻿using System.ComponentModel.Composition;
using System.Waf.Applications;
using HighLandirect.Applications.Views;
using HighLandirect.Domain;
using System.Windows.Input;

namespace HighLandirect.Applications.ViewModels
{
    [Export]
    public class ProductViewModel : ViewModel<IProductView>
    {
        private bool isValid = true;
        private Product product;

        
        [ImportingConstructor]
        public ProductViewModel(IProductView view)
            : base(view)
        {
        }


        public bool IsEnabled { get { return Product != null; } }

        public bool IsValid
        {
            get { return isValid; }
            set
            {
                if (isValid != value)
                {
                    isValid = value;
                    RaisePropertyChanged("IsValid");
                }
            }
        }

        public Product Product
        {
            get { return product; }
            set
            {
                if (product != value)
                {
                    product = value;
                    RaisePropertyChanged("Product");
                    RaisePropertyChanged("IsEnabled");
                }
            }
        }


        public void Focus()
        {
            ViewCore.FocusFirstControl();
        }
    }
}
